package org.shj.thread.basic;

/**
 * @author Shen Huang Jian
 * @date 2019-08-23 14:44
 */
public class SleepDemo {

    private static volatile boolean flag = true;

    public static void main(String[] args){
        MyThread myThread = new MyThread();
        myThread.start();

        try {
            // 下面的语句并不能使 myThread 休眠 1 秒。因为 sleep 是Thread 静态类的方法。
            myThread.sleep(1000);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    static class MyThread extends Thread{
        @Override
        public void run(){
            while(flag){
                //do nothing, just for demo
            }
        }
    }
}
